package com.wondertek.poms.pre.listener;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.google.common.util.concurrent.RateLimiter;
import com.wondertek.poms.common.constant.Constants;
import com.wondertek.poms.pre.manager.StartProcess;

@Component
@RabbitListener(queues = Constants.QUEUE_SYNC_CONTENT) // 监听队列
public class MessageListener {
	@Autowired
    private StartProcess startProcess;
	// 限流令牌桶
	private static RateLimiter rl = RateLimiter.create(Constants.LIMIT_VALUE);
//	private static RateLimiter rl = RateLimiter.create(300);
	
	/**
     * <p><b>Title:</b> receiveContentTopic</p>
     * <p><b>Description:</b> 内容快速同步消息队列（消息快速队列）</p>
     *
     * @param message
     * @author douzi
     */
	@RabbitHandler
    public void receiveContentTopic(String message) {
    	startProcess.fastProcess(message);
		rl.acquire();
    }
}
